package cn.edu.scau.cmi.pengyujin.client;

import java.util.Iterator;
import java.util.Scanner;

import cn.edu.scau.cmi.pengyujin.composite.safe.Organization;
import cn.edu.scau.cmi.pengyujin.composite.safe.Person;
import cn.edu.scau.cmi.pengyujin.composite.safe.Team;

public class SafeCompositeClient {

	public static void main(String[] args) {
		
		
		System.out.println("请输入创建的个人的名字：");
		Scanner scanner = new Scanner(System.in);
		Person person1 = new Person();
		String name = scanner.next();
		person1.setName(name);
		System.out.println("请输入创建的个人的名字：");
		Person person2 = new Person();
		name = scanner.next();
		person2.setName(name);
		System.out.println("请输入创建的团队名字：");
		Team team = new Team();
		name = scanner.next();
		team.setName(name);
		team.addPerson(person1);
		team.addPerson(person2);
		System.out.println("请输入创建的个人的名字：");
		Person person3 = new Person();
		name = scanner.next();
		person3.setName(name);
		System.out.println("请输入创建的个人的名字：");
		Person person4 = new Person();
		name = scanner.next();
		person4.setName(name);
		System.out.println("请输入创建的组织的名字：");
		Organization organization = new Organization();
		name = scanner.next();
		organization.setName(name);
		organization.addPerson(person3);
		organization.addPerson(person4);
		organization.addTeam(team);
		Iterator iterator1 = organization.getTeamList().iterator();
		Iterator iterator2 = organization.getPersonList().iterator();
		while(iterator1.hasNext()) {
			System.out.println("组织："+organization.getName());
			Team team2 = (Team)iterator1.next();
			System.out.println("团队："+team2.getName());
			Iterator iterator3 = team2.getPersonList().iterator();
			System.out.println(team2.getName()+":");
			while(iterator3.hasNext()) {
				Person person = (Person)iterator3.next();
				System.out.println(person.getName());
			}
			while(iterator2.hasNext()) {
				Person person = (Person)iterator2.next();
				System.out.println("个人："+person.getName());
			}
		}
		
		
		
	}

}
